﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ChatServerApplication
{
    public static class Tools
    {
        public static String NL = System.Environment.NewLine;

        public static byte[] ToByteArray(this string s)
        {
            var asciiEncoding = new ASCIIEncoding();
            return asciiEncoding.GetBytes(s);
        }

        public static string ToAsciiString(this byte[] b)
        {
            var asciiEncoding = new ASCIIEncoding();
            return asciiEncoding.GetString(b);
        }

        public static string[] ToAsciiString(this byte[] b, string sep)
        {
            string[] array = new string[] {sep};
            var asciiEncoding = new ASCIIEncoding();
            return asciiEncoding.GetString(b).Split(array, StringSplitOptions.None);
        }

        public static string[] ToAsciiString(this string s, string sep)
        {
            string[] array = new string[] { sep };
            return s.Split(array, StringSplitOptions.None);
        }

    }
}
